package com.shigen.file.controller;

import com.shigen.file.annotation.RequestLimit;
import com.shigen.file.common.Result;
import com.shigen.file.entity.Visitors;
import com.shigen.file.service.IVisitorsService;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 访客记录表 前端控制器
 * </p>
 *
 * @author shigen.fu
 * @since 2022-06-04
 */
@RestController
@RequestMapping(value = "visitors")
public class VisitorsController {

  @Resource
  private IVisitorsService visitorsService;

  /**
   * 浏览数据的添加
   */
  @RequestLimit
  @PostMapping(value = "public/add")
  public Result<String> add(@RequestBody Visitors visitors, HttpServletRequest request) {
    int result = visitorsService.addVisitor(visitors, request);
    return result > 0 ? Result.success("成功") : Result.err("失败");
  }

}
